package com.thor.palmmall.rest.order;

import org.springframework.beans.factory.annotation.Autowired;

import com.thor.commons.exception.ThorServiceException;
import com.thor.palmmall.rest.order.converter.AProductProm3Converter;
import com.thor.palmmall.rest.order.converter.SProductPromParamFilterConverter;
import com.thor.palmmall.spi.common.SResponse;
import com.thor.palmmall.spi.order.SProductProm3;
import com.thor.palmmall.spi.order.SProductPromService;

public class AProductPromServiceImpl implements AProductPromService {

  @Autowired
  private SProductPromService sProductPromService;

  @Override
  public AProductProm3 getProductProms(AProductPromParamFilter filter) throws ThorServiceException {
    SResponse<SProductProm3> resp = sProductPromService
        .getProductProms(SProductPromParamFilterConverter.getInstance().convert(filter));

    if (resp.isSuccess()) {
      return AProductProm3Converter.getInstance().convert(resp.getBody());
    } else {
      throw new ThorServiceException("无法查询到促销：" + resp.getMessage());
    }

  }

}
